This application is based on applications Nos. 11-92061, 11-92072 and 11-92085 filed in Japan, the contents of which are incorporated herein by reference.
Image Processing Apparatus And Method for Recognizing Specific Pattern and Recording Medium Having Image Processing Program Recorded Thereon.
1. Technical Field of the Invention
The present invention relates to an image processing technique, and more particularly to a technique for recognizing a specific pattern constituted by a plurality of elements having a predetermined positional relationship with each other.
2. Related Art
Conventionally, the position of a specific pattern included in an image has been detected and a pattern matching process has been carried out to recognize the shape of the specific pattern by storing data on each pixel of an image fetched into a camera or the like as binary data or multivalued data in an image memory and collating, for each pixel, the stored data with data on each pixel of a reference pattern specifying a specific pattern which has been stored in a memory in advance. In this collation, the whole image has been scanned while shifting the reference pattern every pixel for an image retrieving the specific pattern in the x or y direction of the image. In this case, when a specific pattern constituted by a plurality of elements having a predetermined relationship with each other is retrieved, reference patterns including all these specific patterns are prepared for scanning the whole image, thereby performing pattern matching.
In this method, however, the pixel of the image where a specific pattern is to be retrieved and the pixel of the reference pattern are shifted and collated every pixel. Therefore, there has been a problem in that it takes a very long time to collate the patterns. Moreover, when the direction of the specific pattern included in the image is not constant, that is, is not coincident with that of the reference pattern, it is necessary to generate a plurality of reference patterns which are rotated by a predetermined different amount or to prepare a plurality of reference patterns in advance, thereby carrying out the above-mentioned collation for each reference pattern.
In order to solve the above-mentioned problem, the present invention provides an image processing apparatus and method and a recording medium having an image processing program recorded thereon which can reliably and quickly detect, from an image, a pattern comprising a plurality of elements and being specified by the relative positional relationship between the elements.
In a first aspect of the invention, an image processing apparatus for retrieving a pattern from an image is provided. The pattern comprises a plurality of elements having a specific positional relationship with each other. The apparatus comprises a reference element detecting unit for detecting two of the elements from the image, an element position calculating unit for calculating positions of residual elements other than the two detected elements based on coordinates of the two detected elements, a residual element detecting unit for detecting the residual elements in the positions calculated by the element position calculating unit, and a pattern retrieving unit for retrieving the pattern based on the two elements detected by the reference element detecting unit and the residual elements detected by the residual element detecting unit.
In a second aspect of the invention, an image processing method is provided for retrieving a pattern from an image. The pattern comprises a plurality of elements having a specific positional relationship with each other. The method comprises detecting two of the elements from the image, calculating positions of residual elements other than the two detected elements based on coordinates of the two detected elements, detecting the residual elements in the calculated positions, and retrieving the pattern based on the detected two elements and the detected residual elements.
In a third aspect of the invention, a computer readable recording medium is provided. The recording medium stores a program for controlling the computer to retrieve a pattern from an image. The pattern comprises a plurality of elements having a specific positional relationship with each other. The program is capable of executing the following functions: a reference element detecting function for detecting two of the elements from the image; an element position calculating function for calculating positions of residual elements other than the two detected elements based on coordinates of the two detected elements; a residual element detecting function for detecting the residual elements in the positions calculated by the element position calculating function; and a pattern retrieving function for retrieving the pattern based on the two elements detected by the reference element detecting unit and the residual elements detected by the residual element detecting function.
In a forth aspect of the invention, the apparatus comprises a unit for setting a size of a search region of which a size in a vertical scanning direction is greater than a size of the specific pattern in the direction by a first amount or more, and a size in a horizontal scanning direction is greater than the size of the specific pattern in the direction by a second amount or more, a unit for determining a position of the search region by moving the search region by the first amount in the vertical scanning direction during vertical scanning and moving the search region by the second amount in the horizontal scanning direction during the horizontal scanning, and a unit for retrieving the specific pattern in the search region of which position is determined.
In a fifth aspect of the invention, the method comprises setting a size of a search region of which a size in a vertical scanning direction is greater than a size of the specific pattern in the direction by a first amount or more, and a size in a horizontal scanning direction is greater than the size of the specific pattern in the direction by a second amount or more, determining a position of the search region by moving the search region by the first amount in the vertical scanning direction during vertical scanning and moving the search region by the second amount in the horizontal scanning direction during the horizontal scanning and retrieving the specific pattern in the search region of which position is determined.
In a sixth aspect of the invention, a computer readable recording medium stores the program being capable of executing the following functions: a function for setting a size of a search region of which a size in a vertical scanning direction is greater than a size of the specific pattern in the direction by a first amount or more, and a size in a horizontal scanning direction is greater than the size of the specific pattern in the direction by a second amount or more; a function for determining a position of the search region by moving the search region by the first amount in the vertical scanning direction during vertical scanning and moving the search region by the second amount in the horizontal scanning direction during the horizontal scanning; and a function for retrieving the specific pattern in the search region of which position is determined.
In a seventh aspect of the invention, an image processing apparatus comprises a position detecting unit for detecting positions of the elements from the image, a position information holding unit for holding information about the positions of the elements which are detected by the position detecting unit and a pattern specifying unit for retrieving elements on the image based on the position information held in the position information holding unit, and specifying the pattern from the retrieved elements.
In an eighth aspect of the invention, an image processing method comprises detecting positions of the elements from the image, holding information about the detected positions of the elements, retrieving elements on the image based on the held position information, and specifying the pattern from the retrieved elements.
In a ninth aspect of the invention, a computer readable recording medium storing a program being capable of executing the following functions: a position detecting function for detecting positions of the elements from the image; a position information holding function for holding information about the positions of the elements which are detected by the position detecting function; and a pattern specifying function for retrieving elements on the image based on the position information held in the position information holding function, and specifying the pattern from the retrieved elements.